import java.util.Scanner;

public class 实训项目 {
    public static void main(String[] args) {

        System.out.println("欢迎来到ATM自动取款机");
        String uname = "admin";
        String upass = "123456";
        while (true) {
        System.out.println("请选择服务项目");
        System.out.println("1----登录");
        System.out.println("2----注册");
        System.out.println("3----改密");
        System.out.println("4----退出");
        System.out.println();
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();


            if (n == 1) {
                System.out.println("欢迎登录");
                System.out.println("请输入账户");

                String uname1 = scan.next();
                System.out.println("请输入密码");

                String upass1 = scan.next();
                System.out.println("请选择业务");
                double money = 10000;
                if (uname1.equals(uname) && upass1.equals(upass)) {
                    while (true) {
                        System.out.println("1----取款");
                        System.out.println("2----存款");
                        System.out.println("3---查询");
                        System.out.println("4----返回");

                        int m = scan.nextInt();
                        if (m == 1) {
                            System.out.println("取款");
                            System.out.println("您的银行卡目前的余额为" + money);
                            System.out.println("请输入取款金额");
                            double qkje = scan.nextDouble();

                            money -= qkje;
                            System.out.println("您本次的取款金额为" + qkje);
                            System.out.println("您的余额为：" + money);

                        }
                        if (m == 2) {
                            System.out.println("存款");
                            System.out.println("请输入存款金额");
                            double cr = scan.nextDouble();
                            money = money + cr;
                            System.out.println("您本次的存款金额为" + cr);
                            System.out.println("您的余额为：" + money);

                        }
                        if (m == 3) {
                            System.out.println("查询");
                            System.out.println("您的银行卡余额为" + money);
                        }
                        if (m == 4) {
                            break;
                        }
                    }
                }else {
                    System.out.println("用户名/密码输入错误！");
                }


            }
            if (n == 2) {
                System.out.println("注册");



            }
            if (n == 3) {
                System.out.println("改密--------");
                System.out.println("请输入旧密码：");
                String upass1 = scan.next();

                if(upass1.equals(upass)){
                    System.out.println("请输入新密码：");
                    String upass3 = scan.next();
                    System.out.println("请确认您输入的新密码：");
                    String upass4 = scan.next();
                    if (upass3.equals(upass4)){
                        upass = upass3;
                        System.out.println("您的新密码为：" + upass);

                    }else {
                        System.out.println("二者对不上");
                    }


                }else {
                    System.out.println("您输入的旧密码错误！");
                }
            }
            if (n == 4) {
                System.out.println("您已退出，谢谢使用");
                break;



            }

    }
} }